home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / gui / gengui.lha / GenGui / Examples / backfill.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  2.6 KB  |  105 lines

  1.  
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <proto/intuition.h>
  5. #include <intuition/intuition.h>
  6. #include <proto/exec.h>
  7. #include <proto/graphics.h>
  8. #include <proto/layers.h>
  9. #include <libraries/gadtools.h>
  10.  
  11. #ifndef GUINAME
  12. #include "test.h"
  13. #else
  14. #include GUINAME
  15. #endif
  16.  
  17. #include <graphics/gfxmacros.h>
  18.  
  19. extern struct IntuitionBase *IntuitionBase;
  20. extern struct GfxBase *GfxBase;
  21. extern struct Library *GadToolsBase;
  22.  
  23. struct LMsg {
  24.    struct Layer *Layer;
  25.    WORD   MinX,MinY;
  26.    WORD   MaxX,MaxY;
  27.    LONG OffsetX,OffsetY;
  28. };
  29.  
  30. ULONG __interrupt __saveds __asm HookFunc(register __a0 struct Hook *hook,
  31.                                  register __a2 struct RastPort *rastport,
  32.                                  register __a1 struct LMsg *msg)
  33. {
  34.    struct RastPort rp=*rastport;
  35.  
  36.    static __chip USHORT bitmap[]={0xaaaa,0x5555,0xaaaa};
  37.  
  38.    rp.Layer=NULL;
  39.  
  40.    SetAPen(&rp,0);
  41.    SetBPen(&rp,2);
  42.    SetDrMd(&rp,JAM2);
  43.  
  44.    /* Adjust the pattern to the window position */
  45.  
  46.    if((msg->MinX ^ msg->MinY ^ msg->OffsetX ^ msg->OffsetY) & 1)
  47.                                          {SetAfPt(&rp,(bitmap+1),1);} else
  48.                                          {SetAfPt(&rp,bitmap,1);}
  49.  
  50.    RectFill(&rp,msg->MinX,msg->MinY,msg->MaxX,msg->MaxY);
  51.  
  52.    return(0);
  53. }
  54.  
  55.  
  56. main()
  57. {
  58.    struct IntuiMessage msg;
  59.    struct Window *win;
  60.    int run=1;
  61.  
  62.    struct Hook hook;
  63.  
  64.    hook.h_Entry=(HOOKFUNC)HookFunc;
  65.    hook.h_SubEntry=NULL;
  66.  
  67.    win=OpenWindowTags(NULL,
  68.             WA_Left,0,WA_Top,20,
  69.             WA_Width,300,WA_Height,100,
  70.             WA_Title,TITLE,
  71.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  72.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW,
  73.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  74.                         |WFLG_SIMPLE_REFRESH
  75.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  76.             WA_MinWidth,300,WA_MinHeight,100,
  77.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  78.             WA_BackFill,&hook,
  79.             TAG_DONE );
  80.  
  81.    if(!win) exit(0);
  82.  
  83.    if(RenderGui(win,&TestPro)) {CloseWindow(win);exit(0);}
  84.  
  85.    while(run) {
  86.       WaitPort(win->UserPort);
  87.       while(Gui_GetIMsg(win->UserPort,&msg)) {
  88.          switch(msg.Class) {
  89.             case IDCMP_CLOSEWINDOW: run=0;
  90.                                     break;
  91.             case IDCMP_NEWSIZE:     ResizeGui(&TestPro);
  92.                                     break;
  93.             case IDCMP_REFRESHWINDOW:
  94.                                     RefreshGui(&TestPro);
  95.                                     break;
  96.             case IDCMP_GADGETUP:
  97.                                     break;
  98.          }
  99.       }
  100.    }
  101.    FreeGui(&TestPro);
  102.    CloseWindow(win);
  103.    return(0);
  104. }
  105.